package xing.application.event.isv.suite.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import xing.application.event.isv.suite.CorpAuthSuiteES;
import xing.application.event.isv.suite.CorpAuthSuiteEvent;
import xing.application.service.isv.suite.CorpSuiteAuthService;

/*******************************************************************************************
 * 类描述：  
 *
 * @author: dustin
 * @date： 2017-9-25 17:00
 * @Description: 同步企业信息监听器
 * @version 1.0.0
 *
 *
 * Version    Date       ModifiedBy                 Content  
 * -------- ---------    ----------         ------------------------  
 * 1.0.0     2017-9-25    Administrator                            
 *******************************************************************************************
 */
@Component
public class CorpAuthSuiteSyncCorpInfoListener {

    @Autowired
    CorpSuiteAuthService corpSuiteAuthService;

    @Async
    @EventListener
    public void register(CorpAuthSuiteEvent corpAuthSuiteEvent) throws Exception{
        System.out.println("corpSync thread:"+Thread.currentThread().getName());
        CorpAuthSuiteES es=corpAuthSuiteEvent.getCorpAuthSuiteES();
        //更新企业信息
        corpSuiteAuthService.syncCorpInfo(es.getSuiteToken(),es.getSuiteKey(),es.getCorpId(),es.getPermanentCode());
    }
}
